import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class GreetingServlet extends HttpServlet 
{
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException 
    {
        response.setContentType("text/html");
        response.setBufferSize(8192);
       
        PrintWriter out = response.getWriter();
       
        out.println("<html>" + "<head><title>Sample Request and Response</title></head>");
       
        out.println("<body  bgcolor=\"#ffffff\">" +
                "<h2>Welcome to Sample Request and Response !!!</h2>" +
                "<font color=\"red\"> <h3>Please provide the following information.</h3></font>" +
                "<form method=\"get\">" +
                "<table>" +
                "<tr>" + 
                "<td>First Name</td><td><input type=\"text\" name=\"firstname\" size=\"25\"></td>" +
                "</tr>" +
                "<tr>" +
                "<td>Last Name</td><td><input type=\"text\" name=\"lastname\" size=\"25\"></td>" +
                "</tr>" +
                "<tr>" +
                "<td>Nick Name</td><td><input type=\"text\" name=\"nickname\" size=\"25\"></td>" +
                "</tr>" +
                "<tr>" +
                "<td>&nbsp</td><td>&nbsp</td>" +
                "</tr>" +
                "<tr>" +
                "<td>Cell. #</td><td><input type=\"text\" name=\"cellnum\" size=\"25\"></td>" +
                "</tr>" +
                "<tr>" +
                "<td>E-Mail Address</td><td><input type=\"text\" name=\"email\" size=\"25\"></td>" +
                "</tr>" +
                "<tr>" +
                "<td>&nbsp</td><td>&nbsp</td>" +
                "</tr>" +
                "</table>" +
                "<input type=\"submit\" value=\"Submit\">" +
                "<input type=\"reset\" value=\"Reset\">" + "</form>");
              
        String firstname = request.getParameter("firstname");
       
        if ((firstname != null) && (firstname.length() > 0)) 
        {
            RequestDispatcher dispatcher =
                    getServletContext().getRequestDispatcher("/ResponseServlet");
            	
            if (dispatcher != null) 
            {
                dispatcher.include(request, response);
            }
        }
       
        out.println("</body></html>");
        out.close();
    }
   
    public String getServletInfo() {
        return "ResponseAndRequestByMark";
    }
}